home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Libris Britannia 4
/
science library(b).zip
/
science library(b)
/
DJGPP
/
QDDVX102.ZIP
/
contrib
/
dvx
/
docs
/
help.doc
< prev
next >
Wrap
Text File
|
1993-07-15
|
21KB
|
607 lines
DESQview/X Help Programming Reference
-------------------------------------
The DESQview/X Help System is a general mechanism for providing
on-line help services to applications. The basic metaphor is a
wire bound flip reference with topics organized into sections.
This widely recognized metaphor provides more information than a
reference card in a more concise presentation than a user manual.
The help notebook contains tabs along its lower edge that allow a
user to turn to the beginning of a particular section, and
navigation buttons down the right hand side. The notebook
displays as much of a topic as possible and lists the number of
pages in the topic as well as the topic number along its lower
edge. The text of a topic may be accented by changes in font and
color, and may contain pictures (or icons). In addition, the text
may contain hypertext links whereupon if a user clicks with the
mouse on a word(s), the notebook automatically jumps to a new
topic. This jump text is usually highlighted in a different color
to distinguish it from regular text. The buttons to the right
allow a user to backtrack through a notebook (after clicking on
jump text and/or section tabs), display the previous or next
topic, display the previous or next page of a topic (paging up
and down) as well as being able to close the notebook (exit).
Help System Components
----------------------
The DESQview/X Help System consists of the following 3
components:
A Help File This is a single file that contains all of the
notebook's text and pictures, instructions for
moving around the notebook (jump instructions)
as well as specifying the section tabs, colors,
etc.
The DESQview/X This is the application that reads the help
Help Engine file, creates the notebook on the display screen
and responds to user input.
Help Interface These routines are used by an application to
Routines instruct the Help engine to display help. They
transparently handle the starting of the Help
engine and the communication that occurs between
the Help engine and the application. In
addition, a stand alone version of these
routines are provided in the form of the
DISPHELP program which can be used from the
command line or in a .DVP file to display a help
notebook.
This chapter first discusses how to create a Help file and is
followed by details on using the help interface routines and the
DISPHELP program.
Help File Structure
-------------------
It is recommended that help files for applications follow this
structure:
Contents A section containing the contents of the notebook
with jumps into the notebook.
Overview A general overview of the application and how to
navigate within it.
Commands Help for all of the commands available in the
application.
Dialogs Help for all of the dialogs that the application
displays.
Errors Help for the individual error messages the
application issues.
Naturally, you may wish to extend or customize this suggestion to
your own particular needs.
The files for this structure would probably be listed in this
order (when presented to HELPLIB.EXE in order to create the help
file):
frcover (Front cover)
contents (Notebook contents)
overview (Overview contents)
oview1 (Overview first topic)
oview2 (Overview second topic)
:
commands (Commands contents)
command1 (First command topic)
command2 (Second command topic)
:
dialogs (Dialogs contents)
dialog1 (First dialog topic)
dialog2 (Second dialog topic)
:
errors (Error contents)
error1 (First error topic)
error2 (Second error topic)
:
bkcover (Back cover)
include1 (Included topics)
include2
:
xpm1 (Picture files)
xpm2
HELPLIB.EXE
-----------
A utility program, HELPLIB.EXE is provided to create and update
help files. The command line options are as follows:
HELPLIB [libname | @responsefile]
libname, the name of an existing library on which to perform
maintenance.
responsefile, the name of a file to read commands from as though
they were entered interactively.
If no response file is specified (i.e. no command line parameter
or only a library name), then HELPLIB.EXE runs interactively with
the following commands available:
Add Add a file to the end of the help file
Burst Burst a help file into its constituent files
Change Rename the name of the help file
Dir List the files added to the help file
Erase Remove a file from the help file
Get Copy a constituent file out of the help file
Insert Insert a file into the help file
Make Create a new help file
Replace Replace a constituent file in the help file
Use Starting using a different help file
Quit Return to DOS
Note that commands may be entered by first letter only.
A response file contains text exactly as it would be entered
interactively with one response per line. An example response
file would be:
m (Make
a new file)
newfile.hlp (name of file)
frcover (front cover)
contents (topic files)
overview
commands
command1
command2
dialogs
errors
bkcover (back cover)
include (include files)
xpmfile.xpm (picture files)
exit (exit signals end of m command)
q (Quit)
A good idea is to create a batch file that uses a response file
like the one shown above:
MAKEHELP.BAT:
del newfile.hlp
helplib @newfile.rsp
This ensures that the topics are merged into the help file in the
correct order.
Example
-------
We shall now build an example help file. The X11 Toolkit diskettes
contain the appropriate help example files.
First, open a DOS Window and change to the correct directory:
Type CD \DJGPP\CONTRIB\DVX\QDECK\HELP\EXAMPLE and press Enter .
Create the new help file:
Type HELPLIB @EXAMPLE.RSP and press Enter.
Now copy the new help file to the help directory and display it:
Type COPY EXAMPLE.HLP \DVX\HELP and press Enter.
Type DISPHELP -F EXAMPLE.HLP and press Enter.
It is recommended that you examine the response file EXAMPLE.RSP
as well as the topic files it uses as an example of writing and
using topic files.
DESQview/X Help Interface
-------------------------
When you have created your DESQview/X Help .HLP file using
HELPLIB, your program can request that Help display a help
notebook at a particular topic. (It should be noted that your
program need not be an X client - the help interface routines do
not rely on the X Window System.)
To do this requires the use of two files - HELP.H and the
DESQview/X System Library. HELP.H is a file that defines error
return codes and prototypes for the Help interface routines -
this file should be included into your program code. The
DESQview/X System Library, LIBSYS.A, contains the Help
interface routines and should be linked in with your program - it
can be found in the \DJGPP\CONTRIB\DVX\LIB directory.
HELP.H is found in the DESQview/X INCLUDE subdirectory, with
djgpp it is \DJGPP\CONTRIB\DVX\INCLUDE.
The four Help interface routines are:
Help_initialize Initialize the help interface
Help_get_sections Get the names of the notebook's sections (the
names on the tabs)
Help_show Display the notebook at a particular topic
Help_terminate Terminate use of the help interface
Typically a program will use the following sequence of calls:
Help_initialize(...);
:
Help_get_sections(...);
/* place section names on Help menu */
:
/* help requested! */
Help_show(a_topic);
:
/* help requested! */
Help_show(another_topic);
:
/* help requested! */
Help_show(and_another_topic);
:
Help_terminate(...);
Note that there is no Help_unshow (or similar command) - a user
may close the help notebook at their discretion or leave it open.
Hence the notebook operates independently of the application. If
the user performs an operation in the application which generates
another Help_show(...) command and its notebook is already open,
then that notebook will appear (if iconified) and is updated to
the specified topic.
How it Works
------------
Understanding how the Help system operates is beneficial in
tracking down problems and using the Help system effectively.
The Help system consists of a Help engine running in its own
DESQview process. This Help engine can accept requests from
multiple applications concurrently and will create multiple
independent notebooks. Even though applications can make requests
to the Help engine directly, the help interface routines are
provided to simplify that process.
Requests are made to the Help engine using the DESQview mailbox
API. When the Help engine has completed the operation it will
return a status code to the sender also using the mailbox API.
Let us now examine what function each of the help interface
routines perform:
Help_initialize
---------------
When called, this routine sets up an account that contains
information that will be sent to the Help system every time a
request to the Help engine is made. At this point no
communication with the Help engine (if it is present) is
performed.
Help_get_sections
-----------------
This function tries to locate the help file on disk (help files
are relative to the Help system's directory and not the
application's). Once the help file is located, the section names
(and their corresponding topics) are extracted and returned to
the calling application.
Note that no communication with the Help engine (if it is
present) is performed.
Help_show
---------
When called, Help_show checks to see if the Help engine is
already running. If it is not, Help_show starts the Help engine
and waits for it to initialize itself. If there are any problems,
Help_show will time out and return an error to the application.
Once the Help engine is running (or was already running in the
first place), Help_show sends a mail message request to the Help
engine. The Help engine performs the request and sends back a
status mail message to Help_show. If there are any problems,
Help_show will time out and return an error to the application.
Help_terminate
--------------
This function sends a message to the Help engine informing it
that the connection to a particular notebook is being severed and
deallocates the account information from local storage.
Help Callback
-------------
There are times when the help interface routines loop constantly
waiting for something to happen (for example, after starting the
Help engine and waiting for it to initialize itself, or after
sending it a message and waiting for a reply).
There can be instances when the help interface routines spend a
significant amount of time (a few seconds) in these loops
(especially when starting the Help engine). During this time, if
a user uncovers or resizes one of the application's windows, the
window will remain blank until the interface routine exits the
busy-wait loop.
To counteract this, the application may specify a callback
routine that will be called whenever the help interface routines
pass through a loop. This callback routine may perform useful
work such as checking and reacting to Expose or ConfigureNotify
events.
The callback routine MUST be of the form:
void helpcallback (void *user_arg);
Help Routines
-------------
A description of each of the 4 interface routines now follows:
Help_initialize()
*****************
Synopsis
--------
#include <help.h>
int Help_initialize (char *display_name, char *win_title,
char *file_name,int start_timeout,
int send_timeout, Help_callback callback,
void *user_arg, HelpID *id);
Description
-----------
Help_initialize is used to initialize the help interface routines
and must be called before any others. It returns a Help ID that
is used in subsequent calls to save the trouble of specifying the
same information (display name, help file name, etc) every time.
This Help id can be thought of as a logical connection to the
Help system.
If an application wishes to display several different notebook
files or use several different displays, Help_initialize must be
called separately for each instance - in each case, a different
Help id will be returned.
display_name, the display where the notebook should appear. If
this parameter is NULL, XDisplayName is used as the display name.
win_title, the window title of the notebook. If this parameter is
NULL, Help! is used.
file_name, the name of the help file to be used. NOTE: this name
should be specified relative to where the Help system
runs,normally the HELP subdirectory of the DESQview/X -
\DVX\HELP. If you store your help file in this directory (as is
recommended), then no path is required in the filename. If you
store your help file with your application, then pass a fully
qualified drive:\path\filenameso that the Help system may locate
the file.
start_timeout, the number of seconds that the help interface
should wait after starting the Help system (using the specified
.DVP) and the system initializing itself. If the interface times
out (after a reasonable number of seconds - 15 or so) a problem
has probably occurred.
send_timeout, the number of seconds that the help interface
should wait after sending a request to the Help system and
waiting for a reply. If the interface times out (after a
reasonable number of seconds - 10 or so) a problem has probably
occurred.
callback, the name of a Help callback function that is called
whenever the help interface is waiting for a reply from the Help
system. This callback routine can handle Expose/Configure Notify
events, for example. If this parameter is NULL, then no callback
will occur.
user_arg, an argument that is always passed to the specified
callback function.
id, <RETURNED> the Help id created for this notebook.
Help_get_sections()
*******************
Synopsis
--------
#include <help.h>
int Help_get_sections(HelpID id, int *ntabs, char**tabs[],
char**topics[]);
Description
-----------
Help_get_sections returns the number of sections and a list of
section names (the tabs appearing along the bottom of a help
notebook). These names may be used on a help menu, for example.
In addition, the corresponding topic names (for use with the
Help_show function) are also returned.
id, Help id (returned by Help_initialize).
ntabs, <RETURNED> the number of sections in the help file.
tabs, <RETURNED> a pointer to an array of character
pointers.These character pointers point to the section names of
the help file (the tabs that appear along the bottom of a
notebook). These section names were created with malloc() and may
be freed with free() when no longer required. In addition the
array of character pointers is also created with malloc() and may
also be freed with free();
topics, <RETURNED> a pointer to an array of character
pointers.These character pointers point to each section's
corresponding topic name in the help file. These topic names were
created with malloc() and may be freed with free() when no longer
required. In addition the array of character pointers is also
created with malloc() and may also be freed with free();
Help_show()
***********
Synopsis
--------
#include <help.h>
int Help_show(HelpID id, char *topic);
Description
-----------
Help_show instructs the Help system to display a notebook at a
particular topic. If a notebook for a particular file is already
open, the Help system will move the notebook to the foreground
and update its contents to the new topic.
id, Help id (returned by Help_initialize).
topic, the name of the topic to display.
Help_terminate()
****************
Synopsis
--------
#include <help.h>
int Help_terminate(HelpID id);
Description
-----------
Help_terminate is used when your application has finished with a
particular notebook (or connection to the Help system).
id, Help id (returned by Help_initialize).
Error Codes
-----------
All help interface routines can return an error code (they all
return an integer value).
These codes are:
H_OK Success
/* Codes returned from Help system to interface routines */
PAD_NO_MEMORY No memory to complete operation
PAD_NO_FILE Help file not found
PAD_BAD_FILE Bad help file
PAD_NO_TOPIC Topic not found
PAD_BAD_CMD Bad request command - contact QOS
PAD_SERVER_NO_MEM Server out of memory
PAD_NO_CONNECT Couldn't connect to Server
(XOpenDisplay failed)
PAD_BAD_VERSION Mismatch between Help system and help
interface version numbers
/* Codes returned from all help interface routines */
H_BAD_ID Help id is invalid
H_NO_MEMORY No memory to complete operation
/* Codes returned by Help_get_sections */
H_NO_FILE Help file not found
H_BAD_FILE Bad help file
H_NO_TOPIC Topic not found
H_BAD_DVPFILE Help .DVP file could not be found/read
H_FNAME_TOO_LONG Help filename is too long
/* Codes returned by Help_show */
H_TIMEOUT Timeout occurred starting/sending message
to Help system
H_SEND_ERROR Error occurred sending message to Help
system
H_RECEIVE_ERROR Error occurred reading message from Help
system
H_START_ERROR Couldn't start Help system - .DVP
couldn't be found, bad .DVP or
out of memory.
Example Program
---------------
The QDDVX Toolkit contains an example program, HELPCALL, that
uses the help interface routines. This program is contained in
the \DJGPP\CONTRIB\DVX\QDECK\HELP directory.
HELPCALL illustrates how to use the help interface routines and
may be compiled using your C compiler.
Using DISPHELP
--------------
Included with DESQview/X is a standalone version of the help
interface routines - DISPHELP.EXE. This program may be used from
the DOS command line or within a .DVP file to display a help
notebook. (Application Manager uses this program to display all
of the notebooks in the Help group.)
DISPHELP.EXE is found in your DESQview/X directory (normally
\DVX).
Note that if an error occurs, DISPHELP displays the error code
returned by the help interface routines - see the Error Codes
section for a description of each error code.
DISPHELP [-display displayname] [-pif pifname] [-spawn] [-file
filename] [-topic topicname] [-name window name] [-help]
DISPHELP accepts the following command line parameters:
-display | -d displayname
displayname, the display the notebook is to appear on. Default:
your DISPLAY DOS variable, or :0 if not defined.
-pif | -p pifname
pifname, the .DVP file to use to start the Help system. Default:
DVXHELP.DVP
-spawn | -s
This switch, when specified, instructs the Help system to spawn a
completely separate notebook, even if an open notebook is already
displaying the same help file.
-file | -f filename
filename, the help file to display. Default: DVXHELP.HLP
-topic | -t topicname
topicname, the topic to display. Default: contents
-name | -n window name
window name, the name of the notebook's window. Default: Help!
-help | -h | -?
Displays a brief reminder of DISPHELP's parameters.